#include <QtGui>
#include <QtCore/QTextCodec>
#include <QTranslator>
//#include "gv_setuphomedialog.h"
//#include "gv_setupchangepwddiaglog.h"
//#include "gv_setuplanguagedialog.h"
//#include "gv_setuptimedialog.h"
#include "gv_zoneshomedialog.h"
#include "gv_zonesconfigurationdetaildialog.h"
#include "gv_zonesconfiguration.h"
#include "gv_zonesstatusdialog.h"
#include "gv_zonesconfigurationdetailinputdialog.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_ZonesConfigurationDetailDialog::GV_ZonesConfigurationDetailDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
    timer = new QTimer;
    connect(timer,SIGNAL(timeout()),this,SLOT(GV_chTime()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(home()));
    connect(BackButton,SIGNAL(clicked()),this,SLOT(home()));
    connect(configuration1Button,SIGNAL(clicked()),this,SLOT(configuration1()));
    connect(configuration2Button,SIGNAL(clicked()),this,SLOT(configuration2()));
    connect(configuration3Button,SIGNAL(clicked()),this,SLOT(configuration3()));
    connect(configuration4Button,SIGNAL(clicked()),this,SLOT(configuration4()));
    connect(configuration5Button,SIGNAL(clicked()),this,SLOT(configuration5()));
    connect(configuration6Button,SIGNAL(clicked()),this,SLOT(configuration6()));
    //
    connect(BelongToButton,SIGNAL(clicked()),this,SLOT(home()));
    //connect(TimeanddateButton,SIGNAL(clicked()),this,SLOT(timeanddate()));
    //connect(LanguageselectionButton,SIGNAL(clicked()),this,SLOT(changelanguage()));

    for(int i = 0; i<6;i++)
    {
        buttonstatus[i]=false;
    }
    timer->start(1000);
}
void GV_ZonesConfigurationDetailDialog::reloadtext()
{
    NameHintsLabel->setText(tr("Zones"));

    BackButton->setText(tr("Back"));
    HelpButton->setText(tr("Help"));
    CancelButton->setText(tr("Cancel"));
    BelongToButton->setText(tr("BelongTo"));
}
void GV_ZonesConfigurationDetailDialog::GV_chTime()
{
    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
}

void GV_ZonesConfigurationDetailDialog::home()
{
    QDialog *dialog1 = new GV_ZonesStatusDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_ZonesConfigurationDetailDialog::configuration1()
{
    if(0)
    {
        QDialog *dialog1 = new GV_ZonesConfigurationDetailInputDialog;
        dialog1->show();
        delete dialog;
        dialog = dialog1;
    }
    else
    {
        if(buttonstatus[0]==false)
        {
            buttonstatus[0]=true;
            configuration1Button->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
        }
        else if(buttonstatus[0]==true)
        {
            buttonstatus[0]=false;
            configuration1Button->setStyleSheet("");
        }
    }
}

void GV_ZonesConfigurationDetailDialog::configuration2()
{
    if(buttonstatus[1]==false)
    {
        buttonstatus[1]=true;
        configuration2Button->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
    }
    else if(buttonstatus[1]==true)
    {
        buttonstatus[1]=false;
        configuration2Button->setStyleSheet("");
    }
}

void GV_ZonesConfigurationDetailDialog::configuration3()
{
    if(buttonstatus[2]==false)
    {
        buttonstatus[2]=true;
        configuration3Button->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
    }
    else if(buttonstatus[2]==true)
    {
        buttonstatus[2]=false;
        configuration3Button->setStyleSheet("");
    }
}

void GV_ZonesConfigurationDetailDialog::configuration4()
{
    if(buttonstatus[3]==false)
    {
        buttonstatus[3]=true;
        configuration4Button->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
    }
    else if(buttonstatus[3]==true)
    {
        buttonstatus[3]=false;
        configuration4Button->setStyleSheet("");
    }
}

void GV_ZonesConfigurationDetailDialog::configuration5()
{
    if(buttonstatus[4]==false)
    {
        buttonstatus[4]=true;
        configuration5Button->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
    }
    else if(buttonstatus[4]==true)
    {
        buttonstatus[4]=false;
        configuration5Button->setStyleSheet("");
    }
}

void GV_ZonesConfigurationDetailDialog::configuration6()
{
    if(buttonstatus[5]==false)
    {
        buttonstatus[5]=true;
        configuration6Button->setStyleSheet("border-image: url(:/images/HomeBg.jpg);");
    }
    else if(buttonstatus[5]==true)
    {
        buttonstatus[5]=false;
        configuration6Button->setStyleSheet("");
    }
}


void GV_ZonesConfigurationDetailDialog::belongto()
{
    QDialog *dialog1 = new GV_ZonesConfigurationDetailInputDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}





